What is a Custom Action


Creating a Custom Action in Wise Packager

Create MSI with custom action for deployment Using Wise Package Studio
  1. Launch Windows Installer Editor
  2. Press OK to Accept default from New Installation File dialog to create a new WSI project file with the "Windows Application" template. If this dialog does not present itself when launched, choose "New" under the "File" menu on the toolbar.
  3. Choose "Product Details" on the left pane and in the right pane enter a name for the product. In this case "Java Runtime Environment" and other details as desired. Although inconsequential to the actual execution of this MSI, a Default Directory should be specified. Click the "Change" button and accept "Program Files" as a default directory.
  4. Choose "Add/Remove Programs" from the left pane and in the right pane check the options for "Hide modify button" and "Hide repair button". Because this is a scripted installation, and not an MSI installation, these options will not be available. You may explain this using the "Comments" field as a message to users that may be looking for this functionality.
  5. Click the "MSI Script" at the bottom of the display to switch to the MSI Script view.
  6. Select the "Execute Immediate" tab at the bottom of the "Installation Sequence" frame.
  7. Scroll to the bottom of the script and click once to select the line just below the "InstallFinalize" Standard Action.
  8. From the action list on the left, double-click "Execute Program From Installation"
  9. In the dialog that appears, enter a name for the custom action (such as "InstallScript") and use the browse button to locate your EXE packaged KiXtart script. To ease future modifications to your MSI package, specify a resilient path for this file, such as a UNC path or consistently mapped drive letter.
  10. Select the "Properties" tab and change the default "Processing" selection to read, "Synchronous, Ignore exit code" and press "OK" to finalize the change. When you do so, the executable will be added to the packages resources. Along with several standard files use for the installation process itself, your script file may be seen in the "Installation Expert" view by selecting "Resources" on the left pane.
  11. As it is now, the script would run each time the MSI were triggered, even during uninstall. To modify this behavior, add a condition for this action by selecting the "Execute Program From Installation (InstallScript)" line and double-clicking "If Statement" from the left pane. For the "If Condition" enter the following: REMOVE <> "ALL" and click "OK". Next, select the line below "Execute Program From Installation (InstallScript)" and double-click the "End Statement" item from the Actions list in the left pane.
  12. As it is now, the script will run the custom action during installation, but will not run at all when uninstalling the MSI. To take uninstall into account, you may copy and paste the three new lines we have added (the If statement, the custom action and the end statement) and paste them immediately below the existing entries so that the three statements appear twice. In the second copy double-click the first line and change the condition to read: REMOVE = "ALL" Next, double-click the "Execute Program From Installation (InstallScript1)" line and change the name of the custom action to something more descriptive (such as "UninstallScript") and in the "Command Line Arguments" field enter "uninstall". You could optionally have a second script for removing the software, but in this example we have taken advantage of the KiXscripts Editor's ability to handle command line switches and incorporated both actions in one script.
external image jre_ca_f2_small.gifFigure 2: MSI Script View of custom action entries (click for full view)
  1. Because your MSI package must contain some file to meet Windows Installer requirements, lets include an INI file that records the installation date and time:- From the "Installation Expert" view, choose "INI Files" in the left pane.- Select the "Program Files" folder and press the "New File" button.- For "INI Filename" enter "ScriptedInstalls.ini" and for "INI Settings" type "[Installed Scripts]" on the first line for a section name, and then "[ProductName]=[Date]" on the next line which are properties that will be interpreted by Windows Installer (for example, "Java Runtime Environment=4/28/2003").- By keeping this dynamic, you may choose to enter the same INI file entry in all your packages for an additional method of tracking package installations.
external image jre_ca_f3_full.gifFigure 3: INI File Details Dialog
  1. Save the WSI project and give it a short, but descriptive name, such as "JRE12.WSI".
  2. Press the "Compile" button at the bottom of the display to generate an MSI file in the directory specified for the WSI file entered in the previous step.